package com.atguigu.sparkcore.day01.singlevalue

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * Author atguigu
 * Date 2020/10/27 15:35
 */
object SampleDemo {
    def main(args: Array[String]): Unit = {
        val conf: SparkConf = new SparkConf().setAppName("SampleDemo").setMaster("local[2]")
        val sc: SparkContext = new SparkContext(conf)
        val list1 = List(30, 50, 70, 60, 10, 20)
        val rdd1: RDD[Int] = sc.parallelize(list1, 2)
        // 参数1: 表示抽到的数据是否放回, 继续有可能被抽到
        val rdd2: RDD[Int] = rdd1.sample(true, 2)
        rdd2.collect.foreach(println)
    
        sc.stop()
        
    }
}
